package com.example.xyxwebbackend001.query;

import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class UserQueryCondition {
    private String tags;
    private String place;

    public List<SortField> getSortFields() {
        List<SortField> sortFields = new ArrayList<>();
        if (tags != null && !tags.isEmpty()) {
            sortFields.add(new SortField("tags", tags));
        }
        if (place != null && !place.isEmpty()) {
            sortFields.add(new SortField("place", place));
        }
        if (sortFields.isEmpty()) {
            sortFields.add(new SortField("createTime", null));
        }
        return sortFields;
    }

    @Getter
    public static class SortField {
        private final String key;
        private final String values;

        public SortField(String key, String values) {
            this.key = key;
            this.values = values;
        }
        @Override
        public String toString() {
            return String.format("SortField{key='%s', values='%s'}", key, values);
        }
    }
}

